package com.chigga.admin.controller;

import com.chigga.admin.domain.dto.UserRegisterUsernameDTO;
import com.chigga.admin.service.UserService;
import com.chigga.common.core.controller.BaseController;
import com.chigga.common.core.domain.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户注册接口
 * @author DefChigga
 */
@Tag(name = "用户注册接口", description = "注册接口描述")
@RestController
@Slf4j
public class UserRegisterController extends BaseController {

    @Resource
    private UserService userService;

    /**
     * 用户注册
     */
    @Operation(summary = "用户名密码注册", description = "用户名密码注册描述")
    @PostMapping("/user/register/username")
    public ResponseResult<Integer> register(@Valid @RequestBody UserRegisterUsernameDTO userRegisterUsernameDTO) {
        log.info("用户注册：{}", userRegisterUsernameDTO);
        return createResponseResult(userService.registerUser(userRegisterUsernameDTO), "注册");
    }
}
